package com.xinqi.modules.course.classroom.controller.app;


import com.xinqi.common.base.response.R;
import com.xinqi.modules.course.classromm.dto.InterationQueryDTO;
import com.xinqi.modules.course.classromm.dto.LiveActCreateDTO;
import com.xinqi.modules.course.classroom.service.LiveActService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 课堂互动app
 *
 * @author liuxingxing
 * @since 2023-03-31 14:16:54
 */

@RestController
@RequestMapping("/app/classroominteraction")
@RequiredArgsConstructor
public class ClassRoomnController {
    /**
     * 服务对象
     */
    private final LiveActService liveActService;


    /**
     * 开始互动
     * @param liveAct 实体对象
     * @return
     */
    @PostMapping("/startInteraction")
    public R<Void> startInteraction(@Validated @RequestBody LiveActCreateDTO liveAct) {
        this.liveActService.startInteraction(liveAct);
        return R.ok();
    }

    /**
     * 结束互动
     * @param queryDTO
     * @return
     */
    @PostMapping("/endInteraction")
    public R<Void> endInteraction(@Validated @RequestBody InterationQueryDTO queryDTO) {
        this.liveActService.endInteraction(queryDTO);
        return R.ok();
    }

    /**
     * 提问
     * @param queryDTO
     * @return
     */
    @PostMapping("/askQuestion")
    public R<Void> askQuestion(@Validated @RequestBody InterationQueryDTO queryDTO) {
        this.liveActService.askQuestion(queryDTO);
        return R.ok();
    }

    /**
     * 统计：互动课件，资料，互动视频，公告等等未读数
     * @return
     */
    @PostMapping("/count/unread/{classId}")
    public R<Map<String, Object>> countUnread(@PathVariable("classId") Long classId) {
        Map<String, Object> res = this.liveActService.countUnread(classId);
        return R.ok(res);
    }

}
